﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CategoryList.aspx.cs" Inherits="Com.CMS263.Web.manage.ManagerCategory.CategoryList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link href="../common/validator.css" rel="stylesheet" type="text/css" /> 
    <script src="/manage/js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
       
        function ShowState(id,ImageName) {
            $.post("Category_action.aspx?op=Valid", { id: id }, function(data) {
                $("#" + ImageName + id).attr("src", "../images/" + data + ".png");
            })
        }
        function del(id, obj) {
            if (confirm('这是一个不可逆的操作，真的要删除此条记录')) {
                $.post("Category_action.aspx?op=delCatetory", { id: id }, function(data) {
                    if (data == "ok") {
                        alert('删除成功');
                        $(obj.parentNode.parentNode).remove();
                    }
                })
            }
        }
        function edits(id) {
            window.location.href = "CategoryEdit.aspx?id=" + id;
        }
        $(function() {
            $("#tab tr").mouseover(function() {
                $("#tab tr").attr("className", "")
                $(this).attr("className", "asd01")
            })
        })
    </script>
    <style type="text/css">
        .style1
        {
            width: 75px;
        }
        .style2
        {
            width: 72px;
        }
        .style3
        {
            height: 46px;
        }
    </style>
</head>
<body>
 <form id="form1" runat="server" enctype="multipart/form-data" method="post">
    <div id="userlist">
        <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" class="table_2">
                    产品类别管理
                    -------<a href="CategoryAdd.aspx">添加类别</a></td>
            </tr>
            <tr>
                <td>
                     类别管理&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="text" id="username" name="key" value='<%=Request["key"] %>' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="submit" id="submit" value="搜索" style="width: 50px" />
                </td>
                </tr>               
            <tr>
                <td class="tdside" align="center">
                    <table width="100%" id="tab" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
                        <tr>
                            <td class="style3">
                                序号
                            </td>
                            <td class="style3">
                                分类名称
                            </td>
                            <td class="style3">
                               分类描述
                            </td>
                            <td class="style3">
                                数量单位
                            </td>
                            <td class="style3">
                                是否显示
                            </td>  
                            <td colspan="2" class="style3">
                                操作
                            </td>
                        </tr>
                        <% if (list.Count> 0)
                           {
                              foreach (Com.CMS263.PO.Category ca in list)
	                            {
                                    if (ca.ParentId==0)
                                    { 
                        %>
                        <tr>
                            <td>
                                <%=ca.Id%>
                            </td>
                            <td>
                                <%=ca.CatName%>
                            </td>
                            <td>
                                <%=ca.CatDesc%>
                            </td>
                            <td>
                                <%=ca.MeasureUnit%>
                            </td>                         
                           
                              <td>   
                               <a href="####" onclick="ShowState(<%=ca.Id%>,'ImagesValid');"><img style="border:0px;"  id="ImagesValid<%=ca.Id%>"  alt="" src="../images/<%=Com.CMS263.Util.StringUtil.GetBoolToString( ca.IsShow,"yes","no")%>.png" /></a>

                            </td>                          
                            <td class="style1">
                                <input type="button" value="修改" style="width: 50px" id="edit" onclick="return edits(<%=ca.Id%>)" />
                            </td>
                            <td class="style2">
                                <input type="submit" value="删除" id="delete" style="width: 50px" onclick="del(<%=ca.Id%>,this);" />
                            </td>                           
                        </tr>
                        <%int j=12;
                            Com.CMS263.BLL.CategoryBLL cateBll = new Com.CMS263.BLL.CategoryBLL();
                            System.Collections.Generic.IList<Com.CMS263.PO.Category> cateList = new System.Collections.Generic.List<Com.CMS263.PO.Category>();
                            cateList = cateBll.FindByParentId(ca.Id);
                            if (cateList.Count>0)
                            {
                            foreach (Com.CMS263.PO.Category caChild in cateList)
                            {                               
                                    %>
                                    <tr>
                            <td>
                                <%=caChild.Id%>
                            </td>
                            <td>
                            <%for (int i = 0; i < j; i++)
			{
			 Response.Write(" &nbsp;");
			}
                                 %>
                                ├&nbsp;<%=caChild.CatName%>
                            </td>
                            <td>
                                <%=caChild.CatDesc%>
                            </td>
                            <td>
                                <%=caChild.MeasureUnit%>
                            </td>                         
                           
                              <td>   
                                <a href="####" onclick="ShowState(<%=caChild.Id%>,'ImagesValid');"><img style="border:0px;" id="ImagesValid<%=caChild.Id%>"  alt="" src="../images/<%=Com.CMS263.Util.StringUtil.GetBoolToString( caChild.IsShow,"yes","no")%>.png" /></a>

                            </td>                          
                            <td class="style1">
                                <input type="button" value="修改" style="width: 50px" id="Button1" onclick="return edits(<%=caChild.Id%>)" />
                            </td>
                            <td class="style2">
                                <input type="submit" value="删除" id="Submit1" style="width: 50px" onclick="del(<%=caChild.Id%>,this);" />
                            </td>                            
                        </tr>
                                    <%}
                            j += 3;
                                }                                
                            }    
                                    }
                                }                         
                           else
                           {
                        %>
                        <tr>
                            <td colspan="10">
                                数据库没有数据!
                            </td>
                        </tr>
                        <%
                            } %>

                    </table>
                </td>
            </tr>
           <tr> <td class="tdside" align="right">
<%=GetPager() %></td></tr>
        </table>
    </div>
  
    </form>
</body>
</html>
